/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import com.google.code.morphia.Datastore;
import com.google.code.morphia.query.Query;
import entity.User;

/**
 *
 * @author AnBoCa
 */
public class UserDao {
    
    public static final String US_ID = "ID";
    public static final String US_NAME = "name";
    public static final String US_EMAIL = "email";
    public static final String US_USERNAME = "userName";
    public static final String US_PASSWORD = "password";
    public static final String US_PHOTOPATH = "photoPath";
    public static final String US_FOLLOWING = "following";
    public static final String US_FOLLOWERS = "followers";
    
    public static final String TW_TEXT = "text";
    public static final String TW_DATE = "date";
    public static final String TW_AUTHORNOMBRE = "authorName";
    public static final String TW_AUTHORID = "authorID";
    public static final String TW_HASHTAGS = "hashTags";

    public static final String HS_USERID = "userId";
    public static final String HS_TWEETID = "tweetId";
    public static final String HS_DATE = "date";
    public static final String HS_RETWEETID = "retweetId";
    public static final String HS_REPLYID = "replyId";

    public static final String DESCENDING = "-";
    
    private Datastore dataStore;
    
    /**
     * hello2
     * hello
     */
    public UserDao(){
        dataStore=DBConnection.getInstance().getDataStore();
    }
    
    public boolean insert(User user){
        dataStore.save(user);
        return true;
    }
    
    public void delete(){
        
    }
    
    public void update(){
        
    }
    
    public User findUsuarioByID(Long id){
        User user;
        Query q = dataStore.createQuery(User.class).field(US_ID).equal(id);
        user = (User) q.get();
        return user;
    }
    
    public User findUsuarioByUserName(String userName){
        User user;
        Query q = dataStore.createQuery(User.class).field(US_USERNAME).equal(userName);
        user = (User) q.get();
        return user;
    }
    
}
